package com.songlanyun.common.enums;


import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

/**
 * 爱心
 */
public class LoveConstant {


    /**
     * 爱心的类型
     * 0：每日签到
     * 1：爱心值兑换公益积分
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum ModelType implements IntegerEnum<Integer> {

        DAILY_ATTENDANCE(0, "每日签到"),
        LOVE_VALUE_EXCHANGE(1, "爱心值兑换公益积分"),
        BUY_GOODS(2, "购习商品送爱心值"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        ModelType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ModelType getByCode(int code) {
            for (ModelType value : ModelType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


}
